#include "WindowHandler.h"

WindowHandler::WindowHandler(void)
{
}


WindowHandler::~WindowHandler(void)
{
}

void WindowHandler::initialize()
{
	// Initialize glfw.
	glfwInit();

	// Initialize glew.
	glewInit();

	// Load OpenGL version 4.1.
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 4);
	glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 1);

	// Only use OpenGLs core profile. This means that depreciated features cannot be used.
	glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
}

void WindowHandler::cleanup()
{
	// Terminates glfw. Closing the current window if there is one.
	glfwTerminate();
}

void WindowHandler::openWindow()
{
	// Opens a new window.
	glfwOpenWindow(0, 0, 0, 0, 0, 0, 0, 0, GLFW_WINDOW);
}

void WindowHandler::closeWindow()
{
	// Closes the current Window.
	glfwCloseWindow();
}

void WindowHandler::setWindowSize(int w, int h)
{
	// Adjusts the size of the window.
	glViewport(0, 0, (GLsizei)w, (GLsizei)h);
}

void WindowHandler::setWindowTitle(std::string title)
{
	// Sets the title of the window.
	glfwSetWindowTitle(title.c_str());
}

void WindowHandler::setWindowPos(int x, int y)
{
	// Moves the window to the right by x pixels, and down by y pixels.
	glfwSetWindowPos(x, y);
}

int WindowHandler::isOpened()
{
	// Returns true if the window is currently opened. False if the window has been closed.
	return glfwGetWindowParam(GLFW_OPENED);
}